import dpkt

class NetArpMsg(dpkt.ethernet.Ethernet):
    def __init__(self,sourceIP,sourceMac,destIP,destMac="\x00\x00\x00\x00\x00\x00"):
        self.__arpmsg = dpkt.arp.ARP()
        self.__arpmsg.sha = sourceMac
        self.__arpmsg.spa = sourceIP
        self.__arpmsg.tpa = destIP
        self.__arpmsg.tha = destMac
        self.__arpmsg.pln = 4
        
        self.data = self.__arpmsg
        
        self.type = dpkt.ethernet.ETH_TYPE_ARP
        self.src = sourceMac
        
        if self.__arpmsg.tha == "\x00\x00\x00\x00\x00\x00":
            self.__arpmsg.op = dpkt.arp.ARP_OP_REQUEST
            self.dst = "\xff\xff\xff\xff\xff\xff"
        else:
            self.__arpmsg.op = dpkt.arp.ARP_OP_REPLY
            self.dst = destMac
        

